{% extends "calendario/base.html" %}

{%block titulo_calendario %} Calendario  {%endblock%}

{% block contenido %}

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}<br>

<form name="calendario" action="" method="post">
{% csrf_token %}

<p>
  <label for="combo_dias">D&iacute;a </label>
  <select name="combo_dias" id="id_combo_dias">
    {% for dia in dias_mes %}
      <option value="{{ dia }}">{{ dia }}</option>
    {% endfor %}
  </select>
  <label for="combo_meses">Mes: </label>
  <select name="combo_meses" id="id_combo_meses">
    <option value="1">Enero</option>
    <option value="2">Febrero</option>
    <option value="3">Marzo</option>
    <option value="4">Abril</option>
    <option value="5">Mayo</option>
    <option value="6">Junio</option>
    <option value="7">Julio</option>
    <option value="8">Agosto</option>
    <option value="9">Septiembre</option>
    <option value="10">Octubre</option>
    <option value="11">Noviembre</option>
    <option value="12">Diciembre</option>
    </select>
    
    <label for="combo_anhos">A&ntilde;o:</label>    
    <select name="combo_anhos" id="id_combo_anhos">
      {% for x in lista_anhos %}
	<option value="{{ forloop.counter }}">{{ x }}</option>
      {% endfor %}
      </select>


<input type="button" value="Filtrar por d&iacute;a" onClick="javascript:enviarFormulario()">
<br>
<br>

{% comment%}
{% for link in links %}
	<span>
	{% if link.color %}		
		<p class=##FF0000 style="color: #FF0000 font-size: 12pt"><a href="/calendario/dia/{{ link.dia_int }}/{{ mes }}/{{ anho }}">{{ link.dia_str }} {{ link.dia_int }}</a></p><br>
	{% else %}
		<a href="/calendario/dia/{{ link.dia_int }}/{{ mes }}/{{ anho }}">{{ link.dia_str }} {{ link.dia_int }}</a><br>
	{% endif %}
	</span>
{% endfor %}<br>
{% endcomment %}

{% block scripts %}
<script language="javascript">
var shortcut=document.calendario

function darDia(){
txt=shortcut.combo_dias.options[shortcut.combo_dias.selectedIndex].text
return txt
}

function darMes(){
txt=shortcut.combo_meses.options[shortcut.combo_meses.selectedIndex].value
return txt
}

function darAnio(){
txt=shortcut.combo_anhos.options[shortcut.combo_anhos.selectedIndex].text
return txt
}

function construirURL(){
URL="/calendario/dia/"+darDia()+"/"+darMes()+"/"+darAnio()+"/"
return URL
}

function enviarFormulario(){
document.forms["calendario"].action=construirURL()
document.forms["calendario"].method="POST"
document.forms["calendario"].submit()
}
//->
</script>
{%endblock%}
</form>
{%endblock%}
